package part11singleton;

/**
 * @description: 枚举实现单例模式（最佳实现），线程安全且没有资源浪费
 * @author: zhang hang
 * @date: 2024/3/24 15:57.
 * @version: 1.0
 */
public class SingletonTest08 {

    public static void main(String[] args) {
        SingletonEnum singletonEnum01 = SingletonEnum.INSTANCE;
        SingletonEnum singletonEnum02 = SingletonEnum.INSTANCE;
        System.out.println(singletonEnum01 == singletonEnum02);
    }


}


enum SingletonEnum {
    INSTANCE;

    public void sayOK() {
        System.out.println("ok");
    }
}